Migrate from TensorAlgebra macro lazy types to LinearBroadcasted#139
Merged
Migrate from TensorAlgebra macro lazy types to LinearBroadcasted#139
Conversation
Contributor
|
Your PR no longer requires formatting changes. Thank you for your contribution! |
- Delete ScaledGradedArray, ConjGradedArray, AddGradedArray and all macro-generated lazy types - Delete lazyblock, graded_eachblockstoredindex, copy_lazygraded - Replace BC.broadcasted(::GradedStyle/SectorStyle, ...) eager interception with copyto! instantiation-time conversion via tryflattenlinear - Add permutedimsopadd! overloads for GradedArray and SectorArray - Update permutedimsadd! → permutedimsopadd! with op parameter in tensoralgebra.jl - Replace y .*= β with blockwise scaling to avoid broadcasting cycle - Bump TensorAlgebra compat to 0.7.21, 0.8 - Bump version to 0.6.24 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
c5e8df5 to
956eb08
Compare
Block indexing on GradedArray (y[Block(...)]) returns a copy, not a view. Use @view! to get a mutable view into the block, so that permutedimsopadd! writes actually persist in the destination array. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
With instantiation-time broadcast conversion, axis checking happens in Base.Broadcast.combine_axes which throws DimensionMismatch instead of the old ArgumentError from check_graded_broadcast_axes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #139 +/- ##
==========================================
- Coverage 71.90% 70.03% -1.88%
==========================================
Files 11 11
Lines 1164 1118 -46
==========================================
- Hits 837 783 -54
- Misses 327 335 +8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This was referenced Mar 27, 2026
Closed
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Companion PR to ITensor/TensorAlgebra.jl#156 — migrates GradedArrays from the old macro-generated lazy types to the new
LinearBroadcasteddesign.What changed
ScaledGradedArray,ConjGradedArray,AddGradedArrayand all macro-generated lazy typeslazyblock,graded_eachblockstoredindex,copy_lazygraded,check_graded_broadcast_axes,check_sector_broadcast_axesBC.broadcasted(::GradedStyle/SectorStyle, ...)eager interception withcopyto!instantiation-time conversion viatryflattenlinearpermutedimsopadd!overloads forGradedArrayandSectorArrayas the single materialization primitivespermutedimsadd!→permutedimsopadd!withopparameter intensoralgebra.jly .*= βwith blockwise scaling to avoid broadcasting cycle (instantiation-timecopyto!intercepts all broadcasting on these types)similar(::Broadcasted{SectorStyle})(previously not needed since broadcasting was eager)broadcast.jl(230 → 83)Known issues
matricize/contracttests fail — these go throughpermutedimsopadd!onBlockSparseArrayblocks (notGradedArray), where the default implementation wraps inPermutedDimsArrayand broadcasts. Needs investigation — may require aBlockSparseArraypermutedimsopadd!overload or fixing thePermutedDimsArray+BlockSparseArraybroadcast interaction.similar(::Broadcasted{SectorStyle})is a temporary implementation — should be reworked to strip sectors, delegate similar, and re-wrap.Dependencies
Test plan
Pkg.test()pass🤖 Generated with Claude Code